package com.google.code.puertorico

object Player {
  def initial(name: String): Player =
    Player(name = name,
      victoryPoints = 0,
      resources = Resources.initial,
      plantations = List.empty,
      buildings = List.empty);
}

case class Player(name: String, victoryPoints: Int, resources: Resources, plantations: List[Plantation], buildings: List[Building]) {

  def buyBuilding(building: Building) = {
    val newResources = resources.copy(gold = resources.gold - building.cost);
    val newBuildings = building :: buildings
    copy(resources = newResources, buildings = newBuildings)
  }

  // TODO; Naming
  def takeGold(amount: Int): Player = copy(resources = resources.copy(gold = resources.gold + amount));

  def cornOutput: Int = plantations.filter(p => p.enabled).filter(p => p.isInstanceOf[CornPlantation]).size;

  def ownsSmallMarket: Boolean = throw new RuntimeException();

  def staffsSmallMarket: Boolean = throw new RuntimeException();

  def ownsLargetMarket: Boolean = throw new RuntimeException();

  def staffsLargeMarket: Boolean = throw new RuntimeException();

  def ownsOfficeBuilding: Boolean = throw new RuntimeException();

  def staffsOfficeBuilding: Boolean = throw new RuntimeException();

}
